#!/usr/bin/python
#coding=utf-8
import os
import urllib
import sys
import re


#oppo = 'http://bbs.coloros.com/forum.php?mod=phones&code=rom&pid=125'
def read_roms(url):

	page = urllib.urlopen(url)

	html = page.read()
	page.close()

	rom_pattern = re.compile(r'"(http:[^"]+miuirom.xiaomi.com/rom/[^"]+.zip)"')

        rom_list = rom_pattern.findall(html)

        if rom_list != []:
	    for r in rom_list:
		print r


	rom_pattern = re.compile(r'"(http:[^"]+bigota.d.miui.com/[^"]+.zip)"')

        rom_list = rom_pattern.findall(html)

        if rom_list != []:
	    for r in rom_list:
		print r                

for i in range(1, 331):
	u = 'http://embed.bbs.miui.com/download-%d.html' % i
	read_roms(u)
